package Attempt1;

import javax.swing.JScrollPane;

/*
 * Interface.java
 *
 * Created on 04 April 2010, 21:47
 */


/**
 *
 * @author  divo
 */
public class Interface extends javax.swing.JFrame {
	MulticastServer server;
	MulticastClient client;

	/** Creates new form Interface */
	public Interface(MulticastClient client) {
		this.server = server;
		this.client = client;
		initComponents();
	}

	/** This method is called from within the constructor to
	 * initialize the form.
	 * WARNING: Do NOT modify this code. The content of this method is
	 * always regenerated by the Form Editor.
	 */
	// <editor-fold defaultstate="collapsed" desc="Generated Code">
	private void initComponents() {

		receiver_pane = new AppendingTextPane();
		sender_input = new javax.swing.JTextField();
		send_button = new javax.swing.JButton();

		setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
		getContentPane().setLayout(null);

		receiver_pane.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
		receiver_pane.setFocusable(false);
		receiver_pane.setFont(new java.awt.Font("Dialog", 0, 14));
		receiver_pane.setFocusable(false);

		//getContentPane().add(new JScrollPane(receiver_pane));
		scrollpane = new JScrollPane();
		scrollpane.setBounds(10,10,380,230);
		scrollpane.setViewportView(receiver_pane);
		scrollpane.setVisible(true);
		getContentPane().add(scrollpane);
		setVisible(true);




		
		getContentPane().add(sender_input);
		sender_input.setBounds(10, 257, 290, 30);

		send_button.setText("Send");
		send_button.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				send_buttonActionPerformed(evt);
			}
		});
		getContentPane().add(send_button);
		send_button.setBounds(310, 253, 80, 40);

		java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
		setBounds((screenSize.width-410)/2, (screenSize.height-330)/2, 410, 330);
	}// </editor-fold>



	private void send_buttonActionPerformed(java.awt.event.ActionEvent evt) {
		//System.out.println(sender_input.getText());
		//receiver_pane.appendText(sender_input.getText() + "\n");
		client.send(sender_input.getText());
		sender_input.setText("");

	}
	
	public void update(String text){
		receiver_pane.appendText(text + "\n");
	}

	/**
	 * @param args the command line arguments
	 */


	// Variables declaration - do not modify
	private AppendingTextPane receiver_pane;
	private JScrollPane scrollpane;
	private javax.swing.JButton send_button;
	private javax.swing.JTextField sender_input;
	// End of variables declaration

}